<template>
    <!-- 标题区域 -->
    <van-nav-bar title="商品详情" fixed></van-nav-bar>
    <div style="height: 45px;"></div>
    <div v-html="DetailApiData.goods_introduce"></div>
    <van-action-bar>
        <van-action-bar-icon icon="chat-o" text="客服" color="#ee0a24" />
        <van-action-bar-icon icon="cart-o" text="购物车" />
        <van-action-bar-icon icon="star" text="已收藏" color="#ff5000" />
        <van-action-bar-button type="warning" text="加入购物车" @click="goCart" />
        <van-action-bar-button type="danger" text="立即购买" />
    </van-action-bar>
</template>

<script setup>
import { ref } from 'vue'
import { useRoute } from 'vue-router'
const route = useRoute()
console.log(route.params.goods_id)
import { DetailApi } from '@/api/api'
let DetailApiData = ref([])
DetailApi(route.params.goods_id).then(res => {
    console.log('商品详情', res)
    DetailApiData.value = res.data.message
})
import { useCounterStore } from '@/stores/cart'
// 在组件内部的任何地方均可以访问变量 `store` ✨
const store = useCounterStore()
import { useRouter } from 'vue-router'
const router = useRouter()
const goCart = ()=>{
    store.piniaAddCart(DetailApiData.value,route.params.goods_id)
    router.push('/home/cart')
}
</script>

<style lang="scss" scoped></style>
